package cn.gpnusz.oliverwiki.config;

import cn.gpnusz.oliverwiki.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author h0ss
 * @description 拦截器配置
 * @date 2021/10/9 - 3:11
 */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    @Resource
    LoginInterceptor loginInterceptor;

    /**
     * 拦截路径配置
     *
     * @param registry : 拦截器注册
     * @author h0ss
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/user/login",
                        "/category/list",
                        "/ebook/list",
                        "/ebook/search",
                        "/doc/list/**",
                        "/doc/findContent/**",
                        "/doc/vote/**",
                        "/ebook-snapshot/**"
                );
    }
}
